package com.hrc.springbootdemo.mq.rabbitmq.controller;

import com.hrc.springbootdemo.mq.rabbitmq.service.MessageReceiver;
import com.hrc.springbootdemo.mq.rabbitmq.service.MessageSender;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController("/mq")
public class TestController {

    @Resource
    private MessageSender messageSender;

    @Resource
    private MessageReceiver messageReceiver;

    @GetMapping("/send")
    public String sendMessage(@RequestParam String message) {
        messageSender.sendMessage(message);
        return "Message sent!";
    }

    @GetMapping("/receive")
    public String receiveMessage() {
        return messageReceiver.receiveMessageManually().toString();
    }

}